import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  // 修改相关配置
  server: {
    host: '0.0.0.0',
    port: 9527,
    open: true,
    // 配置反向代理
    proxy:{
      '/api': {
        target: 'https://www.fastmock.site/mock/55a477e1e3d0428f7cc5fddece56f8cd   ',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '/api'),
      },
    }
  },
  // 配置路径别名
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@a': fileURLToPath(new URL('./src/api', import.meta.url)),
      '@c': fileURLToPath(new URL('./src/components', import.meta.url)),
      '@u': fileURLToPath(new URL('./src/utils', import.meta.url)),
      '@s': fileURLToPath(new URL('./src/stores', import.meta.url)),
      '@v': fileURLToPath(new URL('./src/views', import.meta.url))
    }
  }
})
